package zjitc.web.servlet;

import zjitc.service.UserService;
import zjitc.service.impl.UserServiceImpl;

import javax.servlet.*;
import javax.servlet.http.*;
import javax.servlet.annotation.*;
import java.io.IOException;

@WebServlet("/delUserServlet")
public class DelUserServlet extends HttpServlet {
    @Override
    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        this.doPost(request, response);
    }

    @Override
    protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        //1. 获取名字
        String name = request.getParameter("name");
        //2. 调用service删除
        UserService service = new UserServiceImpl();
        service.deleteUser(name);
        //3. 跳转到UserListServlet
        request.getRequestDispatcher("/userListServlet").forward(request,response);
    }
}
